<%@page import="com.sinodata.bsm.center.bean.ResTypeBean"%>
<%@page import="com.sinodata.bsm.center.bean.ResBean"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@page import="com.sinodata.bsm.center.util.spring.SpringContextHolder"%>
<%@page import="com.sinodata.bsm.center.service.resource.ResService"%>
<%@ page import="com.sinodata.bsm.common.vo.*" %>
<%@ page import="com.sinodata.bsm.common.utils.*" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<%
ResService service = SpringContextHolder.getBean(ResService.class);
String resid = request.getParameter("resid");
	/**
		主机：1101000000000|Unix主机:1101010000000/Windows主机:1101020000000
		数据库：1102000000000
		中间件_应用中间件：1103000000000
		中间件_消息中间件：1104000000000
		虚拟化：1108000000000
	*/
	List<Long> baseResTypes = new ArrayList<Long>();
	baseResTypes.add(1101000000000L);
	baseResTypes.add(1102000000000L);
	baseResTypes.add(1103000000000L);
	baseResTypes.add(1104000000000L);
	baseResTypes.add(1108000000000L);
	Map<Long,List<Res>> resMap  = new HashMap<Long,List<Res>>();
	for(Long resTypeId:baseResTypes){
	    resMap.put(resTypeId, new ArrayList<Res>());
	}
	ResBean resBean = ResBean.get(Long.valueOf(resid));
	ResBean[] resArray = resBean.children();
	for(ResBean bean:resArray){
	    ResTypeBean parentResTypeBean = bean.type().parent();
	    if(parentResTypeBean!=null){
	        ResType parentResType = parentResTypeBean.resType();
	        if(baseResTypes.contains(parentResType.getId())){
	            resMap.get(parentResType.getId()).add(bean.res());
	        }else{
	            ResTypeBean parentParentResTypeBean = parentResTypeBean.parent();
	            	if(parentParentResTypeBean!=null){
	            	    ResType parentParentResType = parentParentResTypeBean.resType();
	            	    if(baseResTypes.contains(parentParentResType.getId())){
	            	        resMap.get(parentParentResType.getId()).add(bean.res());
	            	    }
	            	}
	        }
	    }
	}
%>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	<meta http-equiv="pragma" content="no-cache" />
	<meta http-equiv="cache-control" content="no-cache" />
	<meta http-equiv="expires" content="0" />
	<%@ include file="../include/taglib.jsp"%>
	<%@ include file="../include/common.jsp"%>
	<%@ include file="../include/table.jsp"%>
<title>中科金财IT综合监控系统</title>
<link href="/bsm/style/default/bsm/tab.css" rel="stylesheet" type="text/css">
	<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery/jcarousellite_1.0.1.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/resources/charts/FusionCharts.js"></script>
<script type="text/javascript">
$(document).ready(function() {

});

</script>
</head>
<body>
  <div class="max">
   		<jsp:include page="viewdetailtop.jsp">
        	<jsp:param name="resid" value="<%=resid %>" ></jsp:param>
         </jsp:include>
	 <!--@end 手机银行系统监控一览-->
      <div class="tabbar">
				<ul>
					<li id="baseLi" class="selected"><a id="baseA" href="#" target="_self" ><span>基础资源</span></a></li>
					<li id="appViewLi" class=""><a id="appViewA" href="viewdetail2.jsp?resid=<%= resid%>"  target="_self" ><span>应用环境</span></a></li>
					<li id="appRelLi" class=""><a id="appRelA" href="viewdetail3.jsp?resid=<%= resid%>" target="_self" ><span>应用关联</span></a></li>
					<li id="eventLi" class=""><a id="eventA" href="xtzc.html" target="eventViewFrame" ><span>事件分析</span></a></li>
				</ul>
				<div class="clear"></div>
		</div>
		<div id="c01">
	<!--tab1-->
			
  <div class="container">
    <div class="column">
	  <div class="HostComputer">
	   <h2>主机</h2>
	   <div class="content">
	   	<%
	   		List<Res> hostList = resMap.get(1101000000000L);
	   		List<Res> databaseList = resMap.get(1102000000000L);
	   		List<Res> middlewareList = resMap.get(1103000000000L);
	   		middlewareList.addAll(resMap.get(1104000000000L));
	   		List<Res> virtulList = resMap.get(1108000000000L);
	   		int hostSize = hostList.size();
	   		int dbSize = databaseList.size();
	   		int addedhostSize=0;
	   		int addeddbSize=0;
	   		int addedmwSize = 0;
	   		int addedviSize = 0;
	   		int d = hostSize-dbSize;
	   		int d2 = middlewareList.size() - virtulList.size();
	   		if(d>0){
	   		    addeddbSize = Math.abs(d);
	   		}else if(d<0){
	   		    addedhostSize = Math.abs(d);
	   		}
	   		if(d2>0){
	   		    addedviSize = d2;
	   		}else if(d2<0){
	   		    addedmwSize = Math.abs(d2);
	   		}
	   		for(Res res:hostList){
	   	%>
	     <div class="por_div">
		 	<img src="/bsm/style/default/bsm/appview/s01.png"/>
			<a href="#" target="" ><p><%=res.getName() %></p><p><%=res.getIp() %></p></a>
			<a href="#" target="_blank"  class="Alarm"><img src="/bsm/style/default/tree/node/res<%=res.getHealthStatus() %>.png"/></a>		 
		 </div>
		 	
		 <%} 
	   		for(int i=0; i<addedhostSize; i++){
	   		    out.println(" <div class='por_div_nothing'></div>");
	   		}
		 
		 %>
		 </div>
		 </div>
	   <div class="Database">
	   <h2>数据库</h2>
	   <div class="content">
	   	<%
	   		for(Res res:databaseList){
	   	%>
	     <div class="por_div">
		 	<img src="/bsm/style/default/bsm/appview/db2.png" />
			<a href="#" target="" ><%=res.getIp() %></a>
			<a href="#" target="_blank"  class="Alarm"><img src="/bsm/style/default/tree/node/res<%=res.getHealthStatus() %>.png"/></a>		 
		 </div>
		 <%} 
	   	for(int i=0; i<addeddbSize; i++){
   		    out.println(" <div class='por_div_nothing'></div>");
   		}
		 %>
 	   </div>
	  </div>
	  
	 </div> 
    <div class="column">
	  <div class="Middleware">
	   <h2>中间件</h2>
	   <div class="content" >
	   	<%
	   		for(Res res:middlewareList){
	   	%>
	     <div class="por_div">
		 	<img src="/bsm/style/default/bsm/appview/was.png" />
			<a href="#" target="" ><%=res.getIp() %></a>
			<a href="#" target="_blank"  class="Alarm"><img src="/bsm/style/default/tree/node/res<%=res.getHealthStatus() %>.png"/></a>		
		 </div>
		 <%} 
	   	for(int i=0; i<addedmwSize; i++){
   		    out.println(" <div class='por_div_nothing'></div>");
   		}
		 %>
	   </div>
	  </div>
	  
	   <div class="Virtualization">
	   <h2>虚拟化</h2>
	   <div class="content">
	   	<%for(Res res:virtulList){ %>
	     <div class="por_div">
		 	<img src="/bsm/style/default/bsm/appview/winpro.png" />
			<a href="#" target="" ><%=res.getIp() %></a>
			<a href="#" target="_blank"  class="Alarm"><img src="/bsm/style/default/tree/node/res<%=res.getHealthStatus() %>.png"/></a>		
		 </div>
		 <%}
	   	for(int i=0; i<addedviSize; i++){
   		    out.println(" <div class='por_div_nothing'></div>");
   		}
	   	%>
 	   </div>
	  </div>
	 </div> 
  </div> 
  <!--@end tab1-->		
		</div>
	</div>
</body>
</html>

